//
//  ViewController.m
//  CATransform3DRotation
//
//  Created by Xwoder on 17/1/30.
//  Copyright © 2017年 Xwoder. All rights reserved.
//

#import "ViewController.h"
#import "UIView+ALQuickFrame.h"

@interface ViewController ()

@property (nonatomic, weak) UIView *orangeView;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    UIView *orangeView = [[UIView alloc] init];
    orangeView.backgroundColor = [UIColor orangeColor];
    orangeView.size = CGSizeMake(320, 320);
    orangeView.center = self.view.center;
    [self.view addSubview:orangeView];
    self.orangeView = orangeView;
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    [UIView animateWithDuration:2 animations:^{
        // 旋转
        self.orangeView.layer.transform = CATransform3DMakeRotation(M_PI, 1, 1, 0);
    } completion:^(BOOL finished) {
        [UIView animateWithDuration:2 animations:^{
            // 复原
            self.orangeView.layer.transform = CATransform3DIdentity;
        }];
    }];
}

@end
